{% extends "tcms_base.html" %}
{% load static %}
{% load attachments_tags %}

{% block subtitle %}Test case - {{ test_case.case_id }}: {{ test_case.summary }}{% endblock %}

{% block custom_stylesheet %}
{% endblock %}

{% block custom_javascript %}
<script type="text/javascript" src="{% static 'js/lib/jquery.dataTables.js' %}"></script>
<script type="text/javascript" src="{% static 'js/testcase_actions.js' %}"></script>
<script type="text/javascript">
Nitrate.Utils.after_page_load(Nitrate.TestCases.Details.on_load);

Nitrate.TestCases.Instance = {
	pk: {{ test_case.pk }},
	product_id: {{ test_case.category.product.pk }},
	category_id: {{ test_case.category_id }},
	author_id: {{ test_case.author_id }},
}
</script>

<script src="{% static 'jquery/dist/jquery.min.js' %}"></script>
<script src="{% static 'js/jsonrpc.js' %}"></script>
{% endblock %}

{% block content_type %}
	<input type="hidden" name="content_type" value="testcases.testcase" />
	<input type="hidden" name="object_pk" value="{{ test_case.pk }}" />
	<input type="hidden" name="name" value="{{ test_case.summary }}" />
	<input type="hidden" name="description" value="{{ test_case.notes }}" />
{% endblock %}

{% block contents %}
<div id="content">
	{% if test_plan %}
	<div id="tcms_values" class="hidden">
		<input id="value_product_id" type="hidden" name="product_id" value="{{ test_plan.product_id }}" />
		<input id="id_case_id" type="hidden" name="case_id" value="{{ test_case.case_id }}" />
	</div>
	{% else %}
	<div id="tcms_values" class="hidden">
		<input id="id_case_id" type="hidden" name="case_id" value="{{ test_case.case_id }}" />
	</div>
	{% endif %}
	<div class="control">
		{% if perms.testcases.change_testcase %}
                <strong>
                    <a href="{% url "testcases-edit" test_case.case_id %}?from_plan={{ test_plan.plan_id }}">EDIT</a>
                </strong>
		{% endif %}
		{% if perms.testcases.add_testcaseplan %}
                <strong>
                    | <a href="{% url "testcases-clone" %}?from_plan={{ test_plan.plan_id }}&case={{ test_case.case_id }}">CLONE</a>
                </strong>
		{% endif %}
                {% if perms.testcases.delete_testcase %}
                <strong>
                    | <a href="{% url 'admin:testcases_testcase_delete' test_case.pk %}">DELETE</a>
                </strong>
                {% endif %}
		{% if test_plan %}
		<span class="right-action">
			<a href="{% url 'test_plan_url_short' test_plan.pk %}">Back to Test Plan</a>
		</span>
		{% endif %}
	</div>
	<h2 id="display_title">{{ test_case.summary }}</h2>
	
	<div class="listinfo_content">
		<fieldset class="no-border">
			<div class="leftlistinfo">
				<div class="listinfo">
					<div class="title grey">Default Tester&nbsp;:</div>
					<div class="name">
						{% if test_case.default_tester	%}
						<span id="display_default_tester"><a href="{% url "tcms-profile" test_case.default_tester.username %}">{{ test_case.default_tester.username }}</a></span>
						{% else %}
						<span>No default tester</span>
						{% endif %}
					</div>
				</div>
				<div class="listinfo">
					<div class="title grey">Product&nbsp;:</div>
					<div class="name">
						<span>{{ test_case.category.product }}</span>
					</div>
				</div>
				<div class="listinfo">
					<div class="title grey">Category&nbsp;:</div>
					<div class="name">
						<span id="display_category" >{{ test_case.category }}</span>
					</div>
				</div>
				<div class="listinfo">
					<div class="title grey">Priority&nbsp;:</div>
					<div class="name"><span id="display_priority" >{{ test_case.priority }}</span></div>
				</div>
				<div class="listinfo">
					<div class="title grey">Status&nbsp;:</div>
					<div class="name"><span id="display_priority" >{{ test_case.case_status }}</span></div>
				</div>
				<div class="listinfo">
					<div class="title grey"><span>Alias&nbsp;:</span></div>
					<div class="name {% if not test_case.alias %}grey{% endif %}">
						<span id="display_script" >{{ test_case.alias|default:'None' }}</span>
					</div>
				</div>
			        <div class="listinfo">
				    <div class="title grey">Notes&nbsp;:</div>
				    <div class="name" style="max-width:800px;"><span id="display_priority" >{{ test_case.notes|urlize|linebreaksbr }}</span></div>
			    </div>
			</div>

			<div class="rightlistinfo">
				<div class="listinfo">
					<div class="title grey">Author&nbsp;:</div>
					<span class="name">
						<a href="{% url "tcms-profile" test_case.author.username %}">
							{{ test_case.author.username }}
						</a>
					</span>
				</div>
				<div class="listinfo">
					<div class="title grey">Created&nbsp;:</div>
					<div class="name">{{ test_case.create_date }}</div>
				</div>	
				<div class="listinfo">
					<div class="title grey">Automated&nbsp;:</div>
					<div class="name">{{ test_case.get_is_automated_status }}</div>
				</div>
				<div class="listinfo">
					<div class="title grey">Requirement&nbsp;:</div>
					<div class="name {% if not test_case.requirement %}grey{% endif %}">
						<span id="display_requirement" >{{ test_case.requirement|default:'None' }}</span>
					</div>
				</div>
				<div class="listinfo">
					<div class="title grey">Script&nbsp;:</div>
					<div class="name {% if not test_case.script %}grey{% endif %}">
						<span id="display_script" >{{ test_case.script|default:'None' }}</span>
					</div>
				</div>

				<div class="listinfo">
					<div class="title grey"><span>Arguments&nbsp;:</span></div>
					<div class="name {% if not test_case.arguments %}grey{% endif %}">
						<span id="display_script">{{ test_case.arguments|default:'None' }}</span>
					</div>
				</div>

				<div class="listinfo">
					<div class="title grey"><span>Reference Link&nbsp;:</span></div>
					<div class="name {% if not test_case.extra_link %}grey{% endif %}">
						<span id="display_script">
						{% if test_case.extra_link %}
							<a href="{{ test_case.extra_link }}">{{ test_case.extra_link }}</a>
						{% else %}
						None
						{% endif %}
						</span>
					</div>
				</div>

		                <div class="listinfo">
			            <div class="title"><a href="/admin/testcases/testcase/{{ test_case.pk }}/history/">View Edit History</a></div>
			        </div>
			</div>
			<div class="clear"></div>
		</fieldset>
	</div>
	
	<div class="Detailform border-1">
		<ul id="contentTab" class="content_tab" >
			<li id="tab_document" class="tab tab_focus">
				<a href="#document" title="document">Document</a>
			</li>
			<li id="tab_attachment" class="tab">
				<a href="#attachment" title="attachment">Attachments (<span id='attachment_count'>{% attachments_count test_case %}</span>)</a>
			</li>
			<li id="tab_case_plan" class="tab">
				<a href="#plan" title="plan">Test plans (<span id='plan_count'>{{ test_case.plan.count }}</span>)</a>
			</li>
			<li id="tab_component" class="tab">
				<a href="#component" title="component">Components (<span id='component_count'>{{ test_case.component.count }}</span>)</a>
			</li>
			<li id="tab_case_tag" class="tab">
				<a href="#tag" title="tag">Tags (<span id='tag_count'>{{ test_case.tag.count }}</span>)</a>
			</li>
			<li id="tab_case_bug" class="tab">
				<a href="#bug" title="bug">Bugs (<span id='case_bug_count'>{{ test_case.case_bug.count }}</span>)</a>
			</li>
			<li id="tab_case_run" class="tab">
				<a href="#case_run" title="case_run">Case Runs (<span id='case_run_count'>{{ test_case_runs.count }}</span>)</a>
			</li>
		</ul>
		<div  id="document" class="Detailform-variety_2 tab_list" style="clear:left;">
			{% include "case/get_text.html" %}
		</div>
		<div id="attachment" class="tab_list"  style="display:none">
			{% include "case/get_attachment.html" %}
		</div>
		<div id="plan" style="display:none" class="tab_list">
			<div class="ajax_loading"></div>
		</div>
		<div id="component" style="display:none" class="tab_list">
			{% include "case/get_component.html" %}
		</div>
		<div id="tag" class="tab_list" style="display:none">
			<div class="ajax_loading"></div>
		</div>
		<div id="bug" class="tab_list" style="display:none">
                    <div id="bug_list">
			{% include "case/get_bug.html" %}
                    </div>
                    {% include "case/add_bug_form.html" %}
		</div>
		 <div id="case_run" class="tab_list" style="display:none">
			{% include "case/get_case_run.html" %}
		</div>
	</div>
</div>
{% endblock %}

